<?php Schema::init(); ?>
<div class="schema_wrapper">
	<?php if ($error != -1) { ?>
		<div class="schema_message">
		<?php if (!$error) {
			Backend::infoMessage('Document updated sucsesfuly');
		} else if ($error == -2) {
			Backend::infoMessage('Document inserted sucsesfuly');
		} else {
			Backend::errorMessage('Error updating document');
		} ?>
		</div>
	<?php } ?>

	<div class="schema_header">
		<?php echo __('Updating document "{%doc-name%}"', array('doc-name' => $info['name'])); ?>
	</div>
	<form action="<?php echo CURRENT_URL, $info['id']; ?>" method="post">
		<div class="schema_tabs">
			<ul class="nav nav-pills">
				<li id="schema_tab_0" class="active">
					<a href="#0" onclick="Core.Schema.openTab(0)"><?php echo __('General'); ?></a>
				</li>
			<?php Schema::drawTabs($schema_file); ?>
			</ul>
		</div>
		<div class="schema_blocks">
			<div class="schema_block" id="schema_block_0">
				<table class="table">
					<colgroup>
						<col class="schema_column_headers" />
						<col class="schema_column_fields" />
					</colgroup>
					<tbody>
						<tr>
							<td class="schema_cell_header">Document name</td>
							<td class="schema_cell_field"><input type="text" id="doc_name" name="doc_name" value="<?php echo Schema::clearValue($info['name']); ?>" class="schema_textfield" /></td>
						</tr>
						<tr>
							<td class="schema_cell_header">Alias</td>
							<td class="schema_cell_field"><input type="text" id="doc_alias" name="doc_alias" value="<?php echo Schema::clearValue($info['alias']); ?>" class="schema_textfield" /></td>
						</tr>
						<tr>
							<td class="schema_cell_header">Status</td>
							<td class="schema_cell_field">
								<select id="doc_status_id" name="doc_status_id" class="schema_select">
									<option value="1"<?php if (1 == intval($info['status_id'])) { ?> selected="selected"<?php } ?>>Opened</option>
									<option value="2"<?php if (2 == intval($info['status_id'])) { ?> selected="selected"<?php } ?>>Closed</option>
								</select>
							</td>
						</tr>
					<?php if (intval($info['insert_user_id']) > 0) { ?>
						<tr>
							<td class="schema_cell_header">Inserted by</td>
							<td class="schema_cell_field"><?php echo User::getName($info['insert_user_id']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['insert_time']) > 0) { ?>
						<tr>
							<td class="schema_cell_header">Inserted at</td>
							<td class="schema_cell_field"><?php echo User::getDate(User::getId(), $info['insert_time']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['update_user_id']) > 0) { ?>
						<tr>
							<td class="schema_cell_header">Updated by</td>
							<td class="schema_cell_field"><?php echo User::getName($info['update_user_id']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['update_time']) > 0) { ?>
						<tr>
							<td class="schema_cell_header">Updated at</td>
							<td class="schema_cell_field"><?php echo User::getDate(User::getId(), $info['update_time']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['delete_user_id']) > 0) { ?>
						<tr>
							<td class="schema_cell_header">Deleted by</td>
							<td class="schema_cell_field"><?php echo User::getName($info['delete_user_id']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['delete_time']) > 0) { ?>
						<tr>
							<td class="schema_cell_header">Deleted at</td>
							<td class="schema_cell_field"><?php echo User::getDate(User::getId(), $info['delete_time']); ?></td>
						</tr>
					<?php } ?>
					</tbody>
				</table>
			</div>
			<?php Schema::drawBlocks($schema_file, 'tbl_documents_fields', 'document_id', $info['id']); ?>
		</div>
		<div class="schema_buttons"><input type="submit" value="Update" class="btn btn-primary" /></div>
	</form>
</div>